from __future__ import division
import OpenGL.GL as ogl
import OpenGL.GLU as oglu

class Unit(object):
	def __init__(self, heightmap, position, colour, mass=43500, engine=507000):
		self.heightmap = heightmap
		self.position = position
		self.colour = colour
		
		self.mass = mass
		self.engine = engine
		
		self.quadric = oglu.gluNewQuadric()
		oglu.gluQuadricOrientation(self.quadric, oglu.GLU_INSIDE)
		self.temp_path = ({}, {})
	
	def update(self):
		pass
	
	def render(self):
		s = self.heightmap.tilesize
		x, y = self.position
		w, h = self.heightmap.width / 2, self.heightmap.height / 2
		height = self.heightmap.unit_heights[y][x]
		
		ogl.glPushMatrix()
		ogl.glTranslatef((x-w+0.5)*s, (y-h+0.5)*s, height)
		ogl.glColor3fv(self.colour)
		ogl.glCullFace(ogl.GL_FRONT)
		ogl.glShadeModel(ogl.GL_SMOOTH)
		oglu.gluSphere(self.quadric, s/4, 16, 16)
		ogl.glPopMatrix()
		
		ogl.glShadeModel(ogl.GL_FLAT)
		ogl.glCullFace(ogl.GL_BACK)				

